package com.config;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.HandlerInterceptor;

/**
 * 全局session校驗
 */
public class SessionInterceptor implements HandlerInterceptor {
	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
		Object user = request.getSession().getAttribute("session_stu");
		if (user == null) {
			request.setAttribute("msg", "没有权限请先登陆");
			request.getRequestDispatcher("/login.html").forward(request, response);
			return false;
		} else {
			return true;
		}
	}
}
